package org.bmi.gwt.examples.array.shared;

import org.bmi.gwt.mi.shared.MiObject;

public class StringArrayObject implements MiObject
{
	private String[] strArray;
	PrinterObject printer;

	public StringArrayObject(String[] str, PrinterObject printer)
	{
		this.strArray = str;
		this.printer = printer;
	}

	public String[][] createArray()
	{
		String[][] array = new String[this.strArray.length][this.strArray.length];

		for (int i = 0; i < this.strArray.length; i++)
			for (int j = 0; j < this.strArray.length; j++)
				array[i][j] = this.strArray[i];

		return array;
	}

	public void print1Array(String[] arr)
	{
		this.printer.printLn("1 dimensional string array test...");

		for (int i = 0; i < arr.length; i++)
			this.printer.print(" " + arr[i]);

		this.printer.printLn("");
	}

	public void print2Array(String[][] arr)
	{
		this.printer.printLn("2 dimensional string array test...");

		for (int i = 0; i < arr.length; i++)
		{
			for (int j = 0; j < arr[i].length; j++)
				this.printer.print(" " + arr[i][j]);

			this.printer.printLn("");
		}
	}
}
